﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary
{
    public class PatientCollection
    {
        //private List<Patient> patientList = new List<Patient>();

        public Patient CreatePatient(int id, string cpr, string name, string address, int zip, string city, int phonenumber, string email)
        {
            Patient newPatient = new Patient(cpr, name, address, zip, city, phonenumber, email);
            GatewayPatient pgw = new GatewayPatient();
            pgw.Create(newPatient);
            return newPatient;
        }

        public void TestData()
        {
            GatewayPatient.Add(new Patient("2512901649", "Max", "Espestok 66", 5210, "Odense NV", 60137091, "fax6@hotmail.com"));
            patientList.Add(new Patient("1", "a", "a", 1, "a", 1, "a"));

        }

        public Patient SearchPatient(string cpr)
        {
            GatewayPatient pgw = new GatewayPatient();
            List<Patient> patientList = pgw.LoadAll();
            foreach (Patient p in patientList)
                {
                    if (cpr == p.Cpr)
                        return p;
                }
                return null;
        }

        public void UpdatePatient(string cpr, string name, string address, int zip, string city, int phonenumber, string email)
        {
            foreach (Patient p in patientList)
            {
                if (cpr == p.Cpr)
                {
                    p.Name = name;
                    p.Address = address;
                    p.Zip = zip;
                    p.City = city;
                    p.Phonenumber = phonenumber;
                    p.Email = email;
                }
            }
        }

        public Patient CreatePatient(string cpr, string name, string adress, string zip, string city, string phoneNr, string email, string injuryType)
        {
            throw new NotImplementedException();
        }
    }
}
